﻿<%@ Page Language="C#" DynamicMasterPageFile="~masterurl/default.master" AutoEventWireup="true" CodeBehind="Dialog.aspx.cs" EnableEventValidation="false" Inherits="NintexCustomWFActions.ExecutePowerShell.Dialog, $SharePoint.Project.AssemblyFullName$" %>
<%@ Register TagPrefix="Nintex" Namespace="Nintex.Workflow.ServerControls" Assembly="Nintex.Workflow.ServerControls, Version=1.0.0.0, Culture=neutral, PublicKeyToken=913f6bae0ca5ae12" %>
<%@ Register TagPrefix="Nintex" Namespace="Nintex.Workflow" Assembly="Nintex.Workflow, Version=1.0.0.0, Culture=neutral, PublicKeyToken=913f6bae0ca5ae12" %>
<%@ Register TagPrefix="Nintex" TagName="ConfigurationPropertySection" src="~/_layouts/NintexWorkflow/ConfigurationPropertySection.ascx" %>
<%@ Register TagPrefix="Nintex" TagName="ConfigurationProperty" src="~/_layouts/NintexWorkflow/ConfigurationProperty.ascx" %>
<%@ Register TagPrefix="Nintex" TagName="DialogLoad" Src="~/_layouts/NintexWorkflow/DialogLoad.ascx" %>
<%@ Register TagPrefix="Nintex" TagName="DialogBody" Src="~/_layouts/NintexWorkflow/DialogBody.ascx" %>
<%@ Register TagPrefix="Nintex" TagName="SingleLineInput" Src="~/_layouts/NintexWorkflow/SingleLineInput.ascx" %>
<%@ Register TagPrefix="Nintex" TagName="PlainTextWebControl" Src="~/_layouts/NintexWorkflow/PlainTextWebControl.ascx" %>
<asp:Content ID="ContentHead" ContentPlaceHolderID="PlaceHolderAdditionalPageHead" runat="server">
    <Nintex:DialogLoad runat="server" />

    <script type="text/javascript" language="javascript">
        function TPARetrieveConfig()
        {
            setPlainTextEditorText('<%= script.ClientID %>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Script']/PrimitiveValue/@Value").text);
            setPlainTextEditorText('<%= signature.ClientID %>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Signature']/PrimitiveValue/@Value").text);

            setRTEValue('<%=var1.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var1']/PrimitiveValue/@Value").text);
            setRTEValue('<%=var2.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var2']/PrimitiveValue/@Value").text);
            setRTEValue('<%=var3.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var3']/PrimitiveValue/@Value").text);
            setRTEValue('<%=var4.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var4']/PrimitiveValue/@Value").text);
            setRTEValue('<%=var5.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var5']/PrimitiveValue/@Value").text);
            setPlainTextEditorText('<%= secure.ClientID %>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Secure']/PrimitiveValue/@Value").text);
            setRTEValue('<%=secureStoreAppId.ClientID%>', configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='SecureStoreAppId']/PrimitiveValue/@Value").text);
            document.getElementById('<%=var1Out.ClientID%>').value = configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var1Output']/Variable/@Name").text;
            document.getElementById('<%=var2Out.ClientID%>').value = configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var2Output']/Variable/@Name").text;
            document.getElementById('<%=var3Out.ClientID%>').value = configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var3Output']/Variable/@Name").text;
            document.getElementById('<%=var4Out.ClientID%>').value = configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var4Output']/Variable/@Name").text;
            document.getElementById('<%=var5Out.ClientID%>').value = configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var5Output']/Variable/@Name").text;
        }

        function TPAWriteConfig()
        {
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Script']/PrimitiveValue/@Value").text = getStringFromPlainTextEditor('<%= script.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Signature']/PrimitiveValue/@Value").text = getStringFromPlainTextEditor('<%= signature.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var1']/PrimitiveValue/@Value").text = getRTEValue('<%= var1.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var2']/PrimitiveValue/@Value").text = getRTEValue('<%= var2.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var3']/PrimitiveValue/@Value").text = getRTEValue('<%= var3.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var4']/PrimitiveValue/@Value").text = getRTEValue('<%= var4.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var5']/PrimitiveValue/@Value").text = getRTEValue('<%= var5.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Secure']/PrimitiveValue/@Value").text = getStringFromPlainTextEditor('<%= secure.ClientID %>');
            configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='SecureStoreAppId']/PrimitiveValue/@Value").text = getRTEValue('<%= secureStoreAppId.ClientID %>');

            var resultOuputCtrl = document.getElementById('<%=var1Out.ClientID%>');
            if (resultOuputCtrl.value.length > 0) {
                configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var1Output']/Variable/@Name").text = resultOuputCtrl.value;
            }
            var resultOuputCtrl = document.getElementById('<%=var2Out.ClientID%>');
            if (resultOuputCtrl.value.length > 0) {
                configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var2Output']/Variable/@Name").text = resultOuputCtrl.value;
            }
            var resultOuputCtrl = document.getElementById('<%=var3Out.ClientID%>');
            if (resultOuputCtrl.value.length > 0) {
                configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var3Output']/Variable/@Name").text = resultOuputCtrl.value;
            }
            var resultOuputCtrl = document.getElementById('<%=var4Out.ClientID%>');
            if (resultOuputCtrl.value.length > 0) {
                configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var4Output']/Variable/@Name").text = resultOuputCtrl.value;
            }
            var resultOuputCtrl = document.getElementById('<%=var5Out.ClientID%>');
            if (resultOuputCtrl.value.length > 0) {
                configXml.selectSingleNode("/NWActionConfig/Parameters/Parameter[@Name='Var5Output']/Variable/@Name").text = resultOuputCtrl.value;
            }
            return true;
        }

        onLoadFunctions[onLoadFunctions.length] = function () {
            dialogSectionsArray["<%= MainControls1.ClientID %>"] = true;
        };
    </script>
</asp:Content>

<asp:Content ID="ContentBody" ContentPlaceHolderID="PlaceHolderMain" runat="Server">

  <Nintex:ConfigurationPropertySection runat="server" Id="MainControls1">
    <TemplateRowsArea>
    <Nintex:ConfigurationProperty runat="server" FieldTitle="Script" RequiredField="True">
       <TemplateControlArea>
        <Nintex:PlainTextWebControl clearFieldOnInsert="true" filter="number" runat="server" id="script" width="600px"></Nintex:PlainTextWebControl>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>
    <Nintex:ConfigurationProperty runat="server" FieldTitle="Signature" RequiredField="False">
       <TemplateControlArea>
        <Nintex:PlainTextWebControl clearFieldOnInsert="true" filter="number" runat="server" id="signature" width="600px"></Nintex:PlainTextWebControl>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>
    <Nintex:ConfigurationProperty runat="server" FieldTitle="$var1" RequiredField="False" Width=600>
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="var1"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty ID="ConfigurationProperty3" runat="server" FieldTitle="$var1 Result" RequiredField="False">
        <TemplateControlArea>
        <Nintex:VariableSelector id="var1Out" runat="server" IncludeTextVars="True"></Nintex:VariableSelector>
        </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="$var2" RequiredField="False">
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="var2"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>
    <Nintex:ConfigurationProperty ID="ConfigurationProperty1" runat="server" FieldTitle="$var2 Result" RequiredField="False">
        <TemplateControlArea>
        <Nintex:VariableSelector id="var2Out" runat="server" IncludeTextVars="True"></Nintex:VariableSelector>
        </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="$var3" RequiredField="False">
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="var3"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty ID="ConfigurationProperty2" runat="server" FieldTitle="$var3 Result" RequiredField="False">
        <TemplateControlArea>
        <Nintex:VariableSelector id="var3Out" runat="server" IncludeTextVars="True"></Nintex:VariableSelector>
        </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="$var4" RequiredField="False">
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="var4"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty ID="ConfigurationProperty4" runat="server" FieldTitle="$var4 Result" RequiredField="False">
        <TemplateControlArea>
        <Nintex:VariableSelector id="var4Out" runat="server" IncludeTextVars="True"></Nintex:VariableSelector>
        </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="$var5" RequiredField="False">
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="var5"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty ID="ConfigurationProperty5" runat="server" FieldTitle="$var5 Result" RequiredField="False">
        <TemplateControlArea>
        <Nintex:VariableSelector id="var5Out" runat="server" IncludeTextVars="True"></Nintex:VariableSelector>
        </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="Secured Encrypted String" RequiredField="False">
       <TemplateControlArea>
        <Nintex:PlainTextWebControl clearFieldOnInsert="true" filter="number" runat="server" id="secure" Width="600px"></Nintex:PlainTextWebControl>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>

    <Nintex:ConfigurationProperty runat="server" FieldTitle="Secure Store App Id" RequiredField="False">
       <TemplateControlArea>
        <Nintex:SingleLineInput clearFieldOnInsert="true" filter="number" runat="server" id="secureStoreAppId"></Nintex:SingleLineInput>
      </TemplateControlArea>
    </Nintex:ConfigurationProperty>


    </TemplateRowsArea>
  </Nintex:ConfigurationPropertySection>

  <Nintex:DialogBody runat="server" id="DialogBody" AllowRunNow="EnableAlways">
  </Nintex:DialogBody>
</asp:Content>
